package com.net.redis_plus.controller;

import com.baomidou.mybatisplus.extension.api.R;
import com.net.redis_plus.pojo.*;
import com.net.redis_plus.service.impl.AdminUserPoServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RequestMapping("/api")
@RestController
public class TestController {

    @Autowired
    private AdminUserPoServiceImpl adminUserPoService;

    @GetMapping("/get_list")
    public JsonData getStr(@RequestParam("page") int page, @RequestParam("rows") int rows){
        List<AdminUserPo> adminUserPos = adminUserPoService.listAllUser(page, rows);
        return JsonData.builderSuccess(adminUserPos);
    }

    @PostMapping("add")
    public JsonData addUser(@RequestBody AdminUserPo adminUserPo){
        adminUserPoService.addUser(adminUserPo);
        return JsonData.builderSuccess("ok");
    }
    @GetMapping("/del")
    public JsonData del(@RequestParam("id") int id){
        AdminUserPo add = adminUserPoService.add(id);
        return JsonData.builderSuccess(add);
    }

    @GetMapping("/del2")
    public String del2(){
        return "del";
    }

    @PostMapping("search")
    public JsonData mySearch(@RequestBody Map<String,Object> reqBody){
        List<AdminUserPo> mySearch = adminUserPoService.findMySearch(reqBody);
        return JsonData.builderSuccess(mySearch);
    }

    @PostMapping("search1")
    public JsonData mySearch(@RequestBody List<ConditionEx> list){
        List<AdminUserPo> mySearch = adminUserPoService.findMySearch(list);
        return JsonData.builderSuccess(mySearch);
    }

}
